//
//  MineListUnDetailViewController.m
//  Mahjong
//
//  Created by KING on 16/9/8.
//  Copyright © 2016年 swift. All rights reserved.
//

#import "MineListUnDetailViewController.h"
#import "Header.h"
#import "MineListNumberTableViewCell.h"
#import "MineListAdressTableViewCell.h"
#import "MineListPayTableViewCell.h"
#import "MineListEraTableViewCell.h"
@interface MineListUnDetailViewController ()
<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic, strong) UITableView *myTableView;
@property (nonatomic, strong) UIView *myView;
@property (nonatomic, strong) UIButton *quitButton;
@property (nonatomic, strong) UIButton *okButton;
@property (nonatomic, strong) UIView *backView;
@end

@implementation MineListUnDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.myTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREENH_HEIGHT-90) style:UITableViewStylePlain];
    self.myTableView.backgroundColor = [UIColor colorWithRed:239/255.0 green:239/255.0 blue:239/255.0 alpha:1];

    [self.view addSubview:self.myTableView];
    self.myTableView.delegate = self;
    self.myTableView.dataSource = self;
    [self.myTableView registerNib:[UINib  nibWithNibName:@"MineListNumberTableViewCell" bundle:nil] forCellReuseIdentifier:@"numbercell"];
    
    [self.myTableView registerNib:[UINib nibWithNibName:@"MineListAdressTableViewCell" bundle:nil] forCellReuseIdentifier:@"adresscell"];
    [self.myTableView registerNib:[UINib nibWithNibName:@"MineListEraTableViewCell" bundle:nil] forCellReuseIdentifier:@"eracell"];
    [self.myTableView registerNib:[UINib nibWithNibName:@"MineListPayTableViewCell" bundle:nil] forCellReuseIdentifier:@"paycell"];
    [self.myTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    [self createButton];
    [self createView];
    self.navigationItem.title = @"订单详情";
    
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"nav_but_back"] style:(UIBarButtonItemStyleDone) target:self action:@selector(backAction)];
    backItem.tintColor = [UIColor grayColor];
    self.navigationItem.leftBarButtonItem = backItem;
    
}

- (void)backAction{
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)createView{
    _backView = [[UIView alloc] initWithFrame:CGRectMake(0, 1000, 100, 100)];
    _backView.backgroundColor = [UIColor lightGrayColor];
    _backView.alpha  = 0.5;
    [self.view addSubview:_backView];
    _myView = [[UIView alloc] initWithFrame:CGRectMake(0, 1000, 260, 160)];
    _myView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:_myView];
    
    
    
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 20, 220, 80)];
    titleLabel.text = @"时间未到确定支付剩余的尾款吗";
    titleLabel.numberOfLines = 0;
    [_myView addSubview:titleLabel];
    
    self.quitButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.quitButton.frame = CGRectMake(20, 100, 100, 40);
    [self.quitButton setTitle:@"取消" forState:UIControlStateNormal];
    [self.quitButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.quitButton.backgroundColor = [UIColor colorWithRed:202/255.0 green:204/255.0 blue:208/255.0 alpha:1];
    [self.myView addSubview:self.quitButton];
    [self.quitButton addTarget:self action:@selector(noAction) forControlEvents:UIControlEventTouchUpInside];
    
    self.okButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.okButton.frame = CGRectMake(140, 100, 100, 40);
    self.okButton.backgroundColor = [UIColor whiteColor];
    [self.okButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.okButton setTitle:@"确定" forState:UIControlStateNormal];
    [self.myView addSubview:self.okButton];
    [_okButton addTarget:self action:@selector(okAction) forControlEvents:UIControlEventTouchUpInside];
    self.okButton.backgroundColor = [UIColor colorWithRed:251/255.0 green:22/255.0 blue:76/255.0 alpha:1];
}
-(void)createButton{
    UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(0, SCREENH_HEIGHT-105, SCREEN_WIDTH, 45)];
    backView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:backView];
    
    
    
    UIButton *okButton = [UIButton buttonWithType:UIButtonTypeCustom];
    okButton.frame = CGRectMake(SCREEN_WIDTH- 100, 5, 90, 35);
    okButton.backgroundColor = [UIColor redColor];
    [okButton setTitle:@"去交尾款" forState:UIControlStateNormal];
    [backView addSubview:okButton];
    [okButton addTarget:self action:@selector(goAction) forControlEvents:UIControlEventTouchUpInside];
    okButton.layer.cornerRadius = 5;

    
}
-(void)goAction{
    [UIView animateWithDuration:0.2 animations:^{
        
        self.myView.frame = CGRectMake(100, 300, 260, 160);
        self.myView.centerX = SCREEN_WIDTH/2;
        self.myView.centerY = SCREENH_HEIGHT/2-100;
        _backView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREENH_HEIGHT);
        
    }];
}
-(void)noAction{
    self.myView.frame = CGRectMake(100, 3000, 260, 160);
    _backView.frame = CGRectMake(100, 1000, SCREEN_WIDTH, SCREENH_HEIGHT);

}
-(void)okAction{
    self.myView.frame = CGRectMake(100, 3000, 260, 160);
    _backView.frame = CGRectMake(100, 1000, SCREEN_WIDTH, SCREENH_HEIGHT);


}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 7;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0) {
        return 2;
    }
    if (section == 2) {
        return 4;
    }
    if (section == 3 || section == 4) {
        return 3;
    }
    return 1;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        
        if (indexPath.row == 0) {
            MineListNumberTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"numbercell"];
            cell.titleLabel.text = @"订单号23489234";
            cell.conLabel.text = @"180455234";
            return cell;
        }
        else {
            MineListAdressTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"adresscell"];
            return cell;
        }
        
    }
    
    if (indexPath.section == 1) {
        MineListEraTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"eracell"];
        
        return cell;
    }
    if (indexPath.section == 2) {
        if (indexPath.row == 0) {
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
            cell.imageView.image = [UIImage imageNamed:@"abc.jpg"];
            cell.textLabel.text = @"麻将桌";
            return cell;
        }
        if (indexPath.row == 1) {
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
            cell.imageView.image = [UIImage imageNamed:@"abc.jpg"];
            cell.textLabel.text = @"转盘";
            return cell;
        } if (indexPath.row == 2) {
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
            cell.imageView.image = [UIImage imageNamed:@"abc.jpg"];
            cell.textLabel.text = @"椅子";
            return cell;
        }  else {
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
            cell.imageView.image = [UIImage imageNamed:@"abc.jpg"];
            cell.textLabel.text = @"水晶牌";
            return cell;
        }
        
        
    }
    if (indexPath.section == 3) {
        if (indexPath.row == 0) {
            MineListNumberTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"numbercell"];
            cell.titleLabel.text = @"设计费";
            cell.conLabel.text = @"¥168";
            
            return cell;
            
        }
        if (indexPath.row == 1) {
            MineListNumberTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"numbercell"];
            cell.titleLabel.text =  @"工费 (工时/5 单价/60)";            cell.conLabel.text = @"总价/¥300";
            
            
            return cell;
            
        }else {
            MineListNumberTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"numbercell"];
            cell.titleLabel.text =  @"预计完成时间";            cell.conLabel.text = @"2016-9-21";
            
            return cell;
            
        }
        
    }
    if (indexPath.section == 4) {
        if (indexPath.row == 0) {
            MineListNumberTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"numbercell"];
            cell.titleLabel.text =  @"运费(送货)";
            cell.conLabel.text = @"¥18";
            
            return cell;
            
        }
        if (indexPath.row == 1) {
            MineListNumberTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"numbercell"];
            cell.titleLabel.text =  @"总价合计";
            cell.conLabel.text = @"¥300";
            
            return cell;
            
        }else {
            MineListNumberTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"numbercell"];
            cell.titleLabel.text =  @"需付定金";
            cell.conLabel.text = @"¥300";
            
            return cell;
            
        }
        
    }
    if (indexPath.section == 5) {
        MineListPayTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"paycell"];
        cell.titleLabel.text = @"付款方式";
        cell.conLabel.text = @"支付宝";
        cell.conImage.image =[UIImage imageNamed:@"but_go"];
        return cell;
        
    }
    else {
        MineListPayTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"paycell"];
        cell.titleLabel.text = @"顺丰门地已接单";
        cell.conLabel.text = @"";
        cell.conImage.image =[UIImage imageNamed:@"me_but_tel@2x"];
        return cell;
        
    }
    
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section == 2) {
        return 35;
    }
    return 10;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        if (indexPath.row == 1) {
            return 80;
        }
    }
    return 40;
}
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
    if (section == 2) {
        return @"定制无聊";
    }
    return nil;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
